package com.sxm.yiwei.pinche;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.squareup.picasso.Picasso;
import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.AppManager;
import com.sxm.yiwei.activitis.FWHiteMeShopActivity;
import com.sxm.yiwei.base.BaseActivity;
import com.sxm.yiwei.beans.pinche.Order;
import com.sxm.yiwei.constant.Common;
import com.sxm.yiwei.constant.Constant;
import com.sxm.yiwei.tools.BookPayActivity;
import com.sxm.yiwei.tools.CallPhone;
import com.sxm.yiwei.tools.CircleTransform;
import com.sxm.yiwei.utils.DateUtil;
import com.sxm.yiwei.views.CircleImage;

import org.xutils.x;

import java.util.ArrayList;

/*
* 乘客订单详情
* */
public class PincheOrderDetailActivity extends BaseActivity {

    private RelativeLayout rl_back;
    private TextView tv_title;
    private TextView tv_style;
    private TextView tv_distance;
    private TextView tv_seats;
    private TextView tv_total_price;
    private TextView tv_depart_time;
    private TextView tv_start_pos;
    private TextView tv_end_pos;
    private TextView tv_loss;
    private TextView tv_phone;
    private TextView tv_words;
    private ImageView img1;
    private ImageView img2;
    private ImageView img3;
    private ImageView img4;
    private CircleImage iv_icon;
    private TextView tv_nickname;
    private TextView tv_recent_come;
    private TextView tv_wei;
    private TextView tv_order_id;
    private TextView tv_start_time;
    private TextView tv_ticket_price;
    private Button btn_cancel_order;
    private Button btn_pay_now;
    private int order_type;
    private int go_type;
    private Order order;
    private LinearLayout ll_loss;
    private TextView text11;
    private TextView text22;
    private LinearLayout ll_images;
    private LinearLayout ll_id_info;
    private View line;
    private TextView tv_tel;
    private View line1;
    private LinearLayout ll_pay_type;
    private LinearLayout ll_pay_time;
    private TextView tv_pay_type;
    private TextView tv_pay_time;
    private View line2;
    private LinearLayout ll_bottom1;
    private LinearLayout ll_bottom2;
    private Button btn_appeal;
    private Button btn_refund;
    private Button btn_change;
    private TextView tv_order_type;
    private TextView tv_title_info;
    private ImageView iv_whoPay;
    private TextView text55;
    private LinearLayout ll_wait_reply;
    private LinearLayout ll_seats_support;
    private TextView tv_seats_support;
    private LinearLayout ll_total;
    private TextView tv_price;
    private ImageView[] imageArray;
    private int position;
    private String orderId;
    private String serviceId;


    @Override
    public void setContentView() {
        order_type = getIntent().getIntExtra("order_type",-1);
        go_type = getIntent().getIntExtra("go_type",-1);
        position = getIntent().getIntExtra("position",-1);
        order = (Order) getIntent().getSerializableExtra("order");
        orderId = getIntent().getStringExtra("order_id");
        serviceId = getIntent().getStringExtra("serviceId");
        setContentView(R.layout.activity_pinche_order_detail);
    }

    @Override
    public void initView() {
        rl_back = (RelativeLayout)findViewById(R.id.rl_back);
        tv_title = (TextView)findViewById(R.id.tv_title);
        tv_style = (TextView)findViewById(R.id.tv_style);
        tv_distance = (TextView)findViewById(R.id.tv_distance);
        tv_seats = (TextView)findViewById(R.id.tv_transfer_fee);
        tv_total_price = (TextView)findViewById(R.id.tv_total_price);
        tv_depart_time = (TextView)findViewById(R.id.tv_depart_time);
        tv_start_pos = (TextView)findViewById(R.id.tv_start_pos);
        tv_end_pos = (TextView)findViewById(R.id.tv_end_pos);
        tv_loss = (TextView)findViewById(R.id.tv_loss);
        tv_phone = (TextView)findViewById(R.id.tv_phone);
        tv_words = (TextView)findViewById(R.id.tv_words);
        img1 = (ImageView)findViewById(R.id.img1);
        img2 = (ImageView)findViewById(R.id.img2);
        img3 = (ImageView)findViewById(R.id.img3);
        img4 = (ImageView)findViewById(R.id.img4);
        iv_icon = (CircleImage)findViewById(R.id.iv_icon);
        tv_nickname = (TextView)findViewById(R.id.tv_nickname);
        tv_recent_come = (TextView)findViewById(R.id.tv_recent_come);
        tv_wei = (TextView)findViewById(R.id.tv_wei);
        tv_order_id = (TextView)findViewById(R.id.tv_order_id);
        tv_start_time = (TextView)findViewById(R.id.tv_start_time);
        tv_ticket_price = (TextView)findViewById(R.id.tv_ticket_price);
        btn_cancel_order = (Button)findViewById(R.id.button1);
        btn_pay_now = (Button)findViewById(R.id.button2);
        ll_loss = (LinearLayout)findViewById(R.id.ll_loss);
        text11 = (TextView)findViewById(R.id.text11);
        text22 = (TextView)findViewById(R.id.text22);
        ll_images = (LinearLayout)findViewById(R.id.ll_images);
        ll_id_info = (LinearLayout)findViewById(R.id.ll_id_info);
        line = findViewById(R.id.line);
        tv_tel = (TextView)findViewById(R.id.tv_tel);
        line1 = findViewById(R.id.line1);
        ll_pay_type = (LinearLayout)findViewById(R.id.ll_pay_type);
        ll_pay_time = (LinearLayout)findViewById(R.id.ll_pay_time);
        tv_pay_type = (TextView)findViewById(R.id.tv_pay_type);
        tv_pay_time = (TextView)findViewById(R.id.tv_pay_time);
        line2 = findViewById(R.id.line2);
        ll_bottom1 = (LinearLayout)findViewById(R.id.ll_bottom1);
        ll_bottom2 = (LinearLayout)findViewById(R.id.ll_bottom2);
        btn_appeal = (Button)findViewById(R.id.btn_appeal);
        btn_refund = (Button)findViewById(R.id.btn_refund);
        btn_change = (Button)findViewById(R.id.btn_change);
        tv_order_type = (TextView)findViewById(R.id.tv_order_type);
        tv_title_info = (TextView)findViewById(R.id.tv_title_info);
        iv_whoPay = (ImageView)findViewById(R.id.iv_whoPay);
        text55 = (TextView)findViewById(R.id.text55);
        ll_wait_reply = (LinearLayout)findViewById(R.id.ll_wait_reply);
        ll_seats_support = (LinearLayout)findViewById(R.id.ll_seats_support);
        tv_seats_support = (TextView)findViewById(R.id.tv_seats_support);
        ll_total = (LinearLayout)findViewById(R.id.ll_total);
        tv_price = (TextView)findViewById(R.id.tv_price);
        imageArray= new ImageView[]{img1, img2, img3, img4};

    }

    @Override
    public void initData() {
        tv_title.setText("订单详情");
        setDataToView();
        //getOrderDetail();
    }
    /*
    * 网络请求赋值
    * */
    private void getOrderDetail() {
        switch (order_type){
            case Constant.WAIT_PAY:
                if (!serviceId.equals("")){
                    httpGetServiceDetail(0);
                }else {
                    httpGetOrderDetail(0);
                }
                break;
            case Constant.WAIT_TAKE:
                httpGetServiceDetail(1);
                break;
            case Constant.WAIT_SURVICE:
                httpGetOrderDetail(1);
                break;
            case Constant.IN_SURVICE:
                httpGetOrderDetail(2);
                break;
            case Constant.WAIT_FINISH:
                httpGetOrderDetail(3);
                break;
            case Constant.FINISHED:
                httpGetOrderDetail(4);
                break;
            case Constant.LOSS:
                httpGetOrderDetail(5);
                break;
            case Constant.EXCEPTION:
                httpGetOrderDetail(6);
                break;
        }
    }
    /*
    * 传参赋值
    * */
    private void setDataToView() {
        if (order_type== Constant.WAIT_PAY&&go_type!=Constant.LONG_HURRY){
            tv_distance.setText(order.getDistance()+"公里");
            tv_seats.setText("座位需求"+order.getSeats()+"个");
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            ll_loss.setVisibility(View.GONE);
            tv_phone.setText(order.getPhone());
            tv_order_id.setText(order.getOrder_code());
            tv_start_time.setText(order.getStart_time());
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_order_type.setText("--待付款");
            line1.setVisibility(View.GONE);
            ll_pay_time.setVisibility(View.GONE);
            ll_pay_type.setVisibility(View.GONE);
            tv_loss.setVisibility(View.GONE);
            if (TextUtils.isEmpty(order.getWords())){
                tv_words.setText("暂无留言");
            }else {
                tv_words.setText(order.getWords());
            }
            if (order.getForm_way()==Constant.RELEASE){
                tv_title.setText("发布详情");
                ll_images.setVisibility(View.GONE);
                line.setVisibility(View.GONE);
                ll_id_info.setVisibility(View.GONE);
                text11.setText("我的联系方式：");
                text22.setText("我的留言：");
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
                if (order.getIs_timeout()==Constant.YES){
                    tv_ticket_price.setText("已超时");
                    btn_pay_now.setText("重新发布");

                }else {
                    /*SpannableString spannableString = new SpannableString("信息未发布,票价100元");
                    spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#fc4c4c")), 6,spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);*/
                    tv_ticket_price.setText("信息未发布,票价"+order.getSingle_money()+"元");
                    btn_pay_now.setText("立即发布");

                }

            }else if (order.getForm_way()==Constant.BUY){
                tv_title.setText("订单详情");
                text11.setText("车主联系方式：");
                text22.setText("车主留言：");
                Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                if (TextUtils.isEmpty(order.getNickname())){
                    tv_nickname.setText("暂无昵称");

                }else {
                    tv_nickname.setText(order.getNickname());

                }
                tv_recent_come.setText("[24h前来过]");// TODO: 2017/11/13 weiyixia
                if (order.getVehicle_type()==Constant.BUS){
                    tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                }else {
                    tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                }
                ArrayList<String> imgList = order.getImgList();
                for (int i = 0; i <imgList.size() ; i++) {
                    x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
                }
                if (order.getIs_timeout()==Constant.YES){
                    tv_ticket_price.setText("已超时");
                }else {
                    tv_ticket_price.setText("车票未购买成功，票价"+order.getSingle_money()+"元");
                    btn_pay_now.setText("购票");
                }
            }
        }else if (order_type==Constant.WAIT_PAY&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--待付款");
            if (order.getIs_timeout()==Constant.YES){
                tv_title.setText("发布详情");
                ll_images.setVisibility(View.GONE);
                line.setVisibility(View.GONE);
                ll_id_info.setVisibility(View.GONE);
                text11.setText("我的联系方式：");
                text22.setText("我的留言：");
                tv_loss.setText("货物体积：");
                ll_pay_type.setVisibility(View.GONE);
                ll_pay_time.setVisibility(View.GONE);
                tv_ticket_price.setText("已超时，运费+保费，共1000元");
                btn_pay_now.setText("重新发布");
            }else {
                if (order.getForm_way()==Constant.RELEASE){
                    tv_title.setText("发布详情");
                    ll_images.setVisibility(View.GONE);
                    line.setVisibility(View.GONE);
                    ll_id_info.setVisibility(View.GONE);
                    text11.setText("我的联系方式：");
                    text22.setText("我的留言：");
                    tv_loss.setText("货物体积：");
                    ll_pay_type.setVisibility(View.GONE);
                    ll_pay_time.setVisibility(View.GONE);
                    tv_ticket_price.setText("信息未发布，运费+保费，共1000元");
                    btn_pay_now.setText("立即发布");
                    tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
                }else {
                    tv_title.setText("车票详情");
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    tv_loss.setText("可载空间：");
                    text11.setText("车主联系方式：");
                    text22.setText("车主留言：");
                    tv_ticket_price.setText("订仓未成功，需运费，保费共100元");
                }
            }


        }else if (order_type==Constant.WAIT_TAKE&&go_type!=Constant.LONG_HURRY){
            tv_distance.setText(order.getDistance()+"公里");
            tv_seats.setText("需求座位"+order.getSeats()+"个");
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            //tv_loss.setText("爽约金："+order.getLoss_money()+"元");
            tv_phone.setText(order.getPhone());
            if (TextUtils.isEmpty(order.getWords())){
                tv_words.setText("乘客很懒，没有留言");
            }else {
                tv_words.setText(order.getWords());
            }
            tv_order_id.setText(order.getOrder_code());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
            }
            tv_start_time.setText(order.getStart_time());
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_order_type.setText("--待接单");
            ll_images.setVisibility(View.GONE);
            line.setVisibility(View.GONE);
            ll_id_info.setVisibility(View.GONE);
            text11.setText("我的电话：");
            text22.setText("我的留言：");
            if (order.getIs_timeout()==Constant.YES){
                tv_ticket_price.setText("已超时");
                btn_pay_now.setVisibility(View.VISIBLE);
                btn_pay_now.setText("重新发布");

            }else {
                String str="<font color='#333333'>待车主接单，感谢您的耐心等待</font>";
                tv_ticket_price.setText(Html.fromHtml(str));
                btn_pay_now.setVisibility(View.GONE);

            }
            ll_loss.setVisibility(View.GONE);
            tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
        } else if (order_type==Constant.WAIT_TAKE&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--待接单");
            tv_title.setText("车票详情");
            tv_loss.setText("货物体积：");
            tv_ticket_price.setText("带车主接单，感谢您的耐心等待");
            btn_pay_now.setVisibility(View.GONE);
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.WAIT_SURVICE&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            if (order.getWho_created()==Constant.HOST){

                tv_seats.setText("座位需求"+order.getSeats()+"个");
            }else {

                tv_seats.setText("提供座位"+order.getSeats()+"个");

            }
            tv_order_type.setText("--待服务");
            tv_tel.setVisibility(View.VISIBLE);
            String str="<font color='#333333'>等待车主开始服务，感谢您的耐心等待</font>";
            tv_ticket_price.setText(Html.fromHtml(str));
            ll_bottom1.setVisibility(View.GONE);
            ll_bottom2.setVisibility(View.VISIBLE);
            ll_loss.setVisibility(View.VISIBLE);
            tv_loss.setText("爽约金："+order.getLoss_money()+"元");
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_phone.setText(order.getPhone());
            tv_words.setText(order.getWords());

            ArrayList<String> imgList = order.getImgList();

            for (int i = 0; i < imgList.size(); i++) {

                x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
            }
            Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
            tv_nickname.setText(order.getNickname());
            tv_recent_come.setText("24h前来过");
            tv_order_id.setText(order.getOrder_code());
            tv_start_time.setText(order.getStart_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
            }
            tv_pay_time.setText(order.getPay_time());
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }

        }else if (order_type==Constant.WAIT_SURVICE&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--待服务");
            tv_title.setText("仓位详情");
            tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            ll_bottom1.setVisibility(View.GONE);
            ll_bottom2.setVisibility(View.VISIBLE);
            btn_change.setVisibility(View.GONE);
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.IN_SURVICE&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_order_type.setText("--服务中");
            if (order.getWho_created()==Constant.HOST){

                tv_seats.setText("座位需求"+order.getSeats()+"个");
            }else {

                tv_seats.setText("提供座位"+order.getSeats()+"个");

            }
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_phone.setText(order.getPhone());
            tv_words.setText(order.getWords());
            tv_nickname.setText(order.getNickname());
            tv_recent_come.setText("[24h前来过]");
            tv_order_id.setText(order.getOrder_code());
            tv_start_time.setText(order.getStart_time());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

            }
            ArrayList<String> imgList = order.getImgList();
            for (int i = 0; i < imgList.size(); i++) {
                x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
            }
            Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
            ll_loss.setVisibility(View.GONE);
            tv_tel.setVisibility(View.VISIBLE);
            line2.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            btn_cancel_order.setText("申诉");
            if (order.getIs_in_car()==Constant.YES){
                btn_pay_now.setText("行程完结");

            }else {
                btn_pay_now.setText("我已上车");

            }
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.IN_SURVICE&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--服务中");
            tv_title.setText("仓位详情");
            tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            btn_pay_now.setText("货已送达");
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.WAIT_FINISH&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            if (order.getWho_created()==Constant.HOST){

                tv_seats.setText("座位需求"+order.getSeats()+"个");
            }else {

                tv_seats.setText("提供座位"+order.getSeats()+"个");

            }
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_phone.setText(order.getPhone());
            tv_words.setText(order.getWords());
            tv_nickname.setText(order.getNickname());
            tv_recent_come.setText("[24h前来过]");
            tv_order_id.setText(order.getOrder_code());
            tv_start_time.setText(order.getStart_time());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

            }
            ArrayList<String> imgList = order.getImgList();
            Log.d("imageArray",imgList.size()+"");
            for (int i = 0; i < imgList.size(); i++) {
                Log.d("imageArray",imageArray[i]+"");
                x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
            }
            Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
            ll_loss.setVisibility(View.GONE);
            tv_tel.setVisibility(View.VISIBLE);
            line2.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            btn_cancel_order.setText("申诉");
            btn_pay_now.setText("行程完结");
            if (order.getIs_finished()==Constant.PASSENGER_FINISHED_HOST_NO){
                tv_order_type.setText("--等待对方完结");

                btn_pay_now.setVisibility(View.GONE);
            }else if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                tv_order_type.setText("--等待我完结");

            }
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.WAIT_FINISH&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_title.setText("仓位详情");
            btn_cancel_order.setText("申诉");
            btn_pay_now.setText("确认送达");
            tv_ticket_price.setVisibility(View.GONE);
            line2.setVisibility(View.GONE);
            if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                tv_order_type.setText("--等待我完结");
            }else {
                tv_order_type.setText("--等待对方完结");
                btn_pay_now.setVisibility(View.GONE);
            }
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.FINISHED&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_order_type.setText("--已完结");
            if (order.getWho_created()==Constant.HOST){

                tv_seats.setText("座位需求"+order.getSeats()+"个");
            }else {

                tv_seats.setText("提供座位"+order.getSeats()+"个");

            }
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_phone.setText(order.getPhone());
            tv_words.setText(order.getWords());
            tv_nickname.setText(order.getNickname());
            tv_recent_come.setText("[24h前来过]");
            tv_order_id.setText(order.getOrder_code());
            tv_start_time.setText(order.getStart_time());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

            }
            ArrayList<String> imgList = order.getImgList();
            for (int i = 0; i < imgList.size(); i++) {
                x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
            }
            Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
            ll_loss.setVisibility(View.GONE);
            tv_tel.setVisibility(View.VISIBLE);
            line2.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            btn_cancel_order.setText("申诉");
            btn_pay_now.setText("再次发布");
            btn_pay_now.setTextColor(getResources().getColor(R.color.hotcolor));
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.FINISHED&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--已完结");
            tv_title.setText("仓位详情");
            tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            line2.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            btn_cancel_order.setText("申诉");
            btn_pay_now.setText("再次发布");
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.LOSS&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_order_type.setText("--爽约单");
            tv_style.setTextColor(getResources().getColor(R.color.textcolors));
            tv_order_type.setTextColor(getResources().getColor(R.color.textcolors));
            tv_distance.setTextColor(getResources().getColor(R.color.textcolors));
            tv_seats.setTextColor(getResources().getColor(R.color.textcolors));
            tv_seats.setText("爽约金 10元");
            text55.setTextColor(getResources().getColor(R.color.textcolors));
            tv_total_price.setTextColor(getResources().getColor(R.color.textcolors));
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_car),null);

            }
            tv_title_info.setVisibility(View.VISIBLE);
            iv_whoPay.setVisibility(View.VISIBLE);
            ll_bottom1.setVisibility(View.GONE);
            tv_loss.setText("需求5个座位");
            line.setVisibility(View.GONE);
            line2.setVisibility(View.GONE);
            ll_id_info.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);


                if (order.getWhy_return().equals("退票")){
                    if (order.getWho_return()==Constant.ME){
                        if (order.getIs_return()==Constant.YES){
                            tv_title_info.setText("我退票，我赔付，爽约金"+order.getPayment()+"元将赔付与对方，剩余金额"+order.getPasserPayback()+"元将退还到您的账户，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.wotuipiao);
                        }else {
                            tv_title_info.setText("我退票，但对方免缴爽约金，不用赔付对方，您缴纳的车票金额"+order.getPasserPayback()+"元将退还到您的账户，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.wotuipiao);
                        }

                    }else {
                        if (order.getIs_return()==Constant.YES){
                            tv_title_info.setText("对方退票，对方赔付，爽约金"+order.getPayment()+"元稍后将到您的账户，请查收，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.duifangtuipiao);
                        }else {
                            tv_title_info.setText("对方退票，但对方免缴爽约金，将不会得到对方的赔偿，您缴纳的车票金额"+order.getPasserPayback()+"元稍后将到您的账户，请查收，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.duifangtuipiao);
                        }

                    }
                }else if (order.getWhy_return().equals("改签")){
                    if (order.getWho_return()==Constant.ME){
                        if (order.getIs_return()==Constant.YES){
                            tv_title_info.setText("我改签，我赔付，爽约金"+order.getPayment()+"元将赔付与对方");
                            iv_whoPay.setImageResource(R.mipmap.wogaiqian);
                        }else {
                            tv_title_info.setText("我改签，但对方免缴爽约金，不用赔付对方，您缴纳的车票金额"+order.getPasserPayback()+"元稍后将到您的账户，请查收，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.wogaiqian);
                        }

                    }else {
                        Toast.makeText(context,"loseTarget返回出错",Toast.LENGTH_SHORT).show();
                    }
                }else if (order.getWhy_return().equals("超时")){
                    if (order.getWho_return()==Constant.ME){
                        if (order.getIs_return()==Constant.YES){
                            tv_title_info.setText("对方申诉我超时，我赔付，爽约金"+order.getPayment()+"元将赔付与对方，剩余金额"+order.getPasserPayback()+"元将退还到您的账户，请查收");
                            iv_whoPay.setImageResource(R.mipmap.wochaoshi);
                        }else {
                            tv_title_info.setText("对方申诉我超时，但对方免缴爽约金，不用赔偿给对方，您缴纳的车票金额"+order.getPasserPayback()+"元将退还到您的账户，请查收");
                            iv_whoPay.setImageResource(R.mipmap.wochaoshi);
                        }

                    }else {
                        if (order.getIs_return()==Constant.YES){
                            tv_title_info.setText("对方超时，对方赔付，爽约金"+order.getPayment()+"元稍后回到您的账户，请查收，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.duifangchaoshi);
                        }else {
                            tv_title_info.setText("对方超时，但对方免缴爽约金，您将不会得到对方的赔偿，您缴纳的票价金额"+order.getPasserPayback()+"元稍后回到您的账户，请查收，感谢您的耐心等待");
                            iv_whoPay.setImageResource(R.mipmap.duifangchaoshi);
                        }

                    }
                }

            tv_distance.setText(order.getDistance()+"公里");
            tv_seats.setText("爽约金"+order.getLoss_money()+"元");
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_loss.setText("需求"+order.getSeats()+"个座位");
            tv_phone.setText(order.getPhone());
            if (TextUtils.isEmpty(order.getWords())){
                tv_words.setText("车主很懒，没有留言");
            }else {
                tv_words.setText(order.getWords());
            }
            tv_order_id.setText(order.getOrder_code());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
            }else if (order.getPay_type()==Constant.RESTPAY){
                tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

            }else {
                tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

            }
            tv_start_time.setText(order.getStart_time());
        }else if (order_type==Constant.LOSS&&go_type==Constant.LONG_HURRY){
            tv_style.setText("长途急件");
            tv_order_type.setText("--爽约单");
            tv_title.setText("车票详情");
            tv_title_info.setVisibility(View.VISIBLE);

            tv_style.setTextColor(getResources().getColor(R.color.textcolors));
            tv_order_type.setTextColor(getResources().getColor(R.color.textcolors));
            tv_distance.setTextColor(getResources().getColor(R.color.textcolors));
            tv_seats.setTextColor(getResources().getColor(R.color.textcolors));
            text55.setTextColor(getResources().getColor(R.color.textcolors));
            tv_total_price.setTextColor(getResources().getColor(R.color.textcolors));

            ll_id_info.setVisibility(View.GONE);
            line.setVisibility(View.GONE);
            line2.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            btn_cancel_order.setText("申诉");
            btn_pay_now.setVisibility(View.GONE);
            iv_whoPay.setVisibility(View.VISIBLE);
            if (order.getWho_return()==Constant.ME){
                iv_whoPay.setImageResource(R.mipmap.wochaoshi);
            }else {
                iv_whoPay.setImageResource(R.mipmap.duifangtuipiao);
            }
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.EXCEPTION&&go_type!=Constant.LONG_HURRY){
            if (go_type==Constant.LONG){
                tv_style.setText("长途");
            }else if (go_type==Constant.CITY){
                tv_style.setText("同城");
            }else if (go_type==Constant.TRAVEL){
                tv_style.setText("旅游");
            }
            tv_title.setText("订单异常订单详情");
            tv_order_type.setText("--订单异常");
            tv_distance.setText(order.getDistance()+"公里");
            tv_total_price.setText(order.getTotal_money()+"元");
            tv_depart_time.setText(order.getDepart_time());
            tv_start_pos.setText(order.getStart_place());
            tv_end_pos.setText(order.getEnd_place());
            tv_loss.setText("需求"+order.getSeats()+"个座位");
            tv_seats.setText("爽约金 "+order.getLoss_money()+"元");

            tv_phone.setText(order.getPhone());
            tv_words.setText(order.getWords());
            tv_order_id.setText(order.getOrder_code());
            tv_pay_time.setText(order.getPay_time());
            if (order.getPay_type()==Constant.ALIPAY){
                if (order.getWho_created()==Constant.PASSENGER){
                    tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
                }else {
                    tv_pay_type.setText("支付宝支付"+order.getLoss_money()+"元");

                }
            }else if (order.getPay_type()==Constant.RESTPAY){
                if (order.getWho_created()==Constant.PASSENGER){
                    tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
                }else {
                    tv_pay_type.setText("余额支付"+order.getLoss_money()+"元");

                }
            }else {
                if (order.getWho_created()==Constant.PASSENGER){
                    tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
                }else {
                    tv_pay_type.setText("微信支付"+order.getLoss_money()+"元");

                }
            }
            tv_start_time.setText(order.getStart_time());
            tv_style.setTextColor(getResources().getColor(R.color.textcolors));
            tv_order_type.setTextColor(getResources().getColor(R.color.textcolors));
            tv_distance.setTextColor(getResources().getColor(R.color.textcolors));
            tv_seats.setTextColor(getResources().getColor(R.color.textcolors));
            text55.setTextColor(getResources().getColor(R.color.textcolors));
            tv_total_price.setTextColor(getResources().getColor(R.color.textcolors));
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_car),null);

            }
            if (order.getIs_reply()==Constant.YES){
                ll_bottom1.setVisibility(View.GONE);
            }else {
                ll_wait_reply.setVisibility(View.VISIBLE);
                btn_pay_now.setVisibility(View.GONE);
                btn_cancel_order.setText("取消申诉");
            }

            line.setVisibility(View.GONE);
            line2.setVisibility(View.GONE);
            ll_id_info.setVisibility(View.GONE);
            tv_ticket_price.setVisibility(View.GONE);
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }
        }else if (order_type==Constant.EXCEPTION&&go_type==Constant.LONG_HURRY){
            tv_title.setText("订单异常订单详情");
            tv_style.setText("长途急件");
            tv_order_type.setText("--订单异常");
            if (order.getVehicle_type()==Constant.BUS){
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
            }else {
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
            }

        }
        tv_distance.setText("100公里");
        if (go_type!=Constant.LONG_HURRY&&order_type!=Constant.WAIT_TAKE&&order_type!=Constant.WAIT_PAY){
            if (order.getWho_created()==Constant.HOST){
                text22.setText("我的留言：");
                text11.setText("我的联系方式：");
            }else {
                text22.setText("车主留言：");
                text11.setText("车主联系方式：");
            }
        }
    }

    private void httpGetOrderDetail(int orderStatus) {
        JSONObject object = new JSONObject();

        if (!TextUtils.isEmpty(orderId)){
            object.put("orderId",orderId);
        }else {
            if (orderStatus==0){
                showToast("此为待付款服务，暂无订单详情");
            }else {
                showToast("orderId为空");
            }
            return;
        }

        object.put("orderStatus",orderStatus+"");
        object.put("role","0");
        Log.e("httpGetOrderDetail","orderId="+orderId+" orderStatus="+orderStatus+" role=0");
        httpGet(Common.HOST+Common.ORDER_DETAIL,object, Constant.ORDER_DETAIL);
    }

    private void httpGetServiceDetail(int serviceStatus){
        JSONObject object = new JSONObject();
        object.put("serviceId",serviceId);
        object.put("role","0");
        object.put("serviceStatus",serviceStatus+"");
        httpGet(Common.HOST+Common.SERVICE_DETAIL,object,Constant.SERVICE_DETAIL);

    }

    @Override
    public void initListener() {
        rl_back.setOnClickListener(this);
        tv_wei.setOnClickListener(this);
        btn_cancel_order.setOnClickListener(this);
        btn_pay_now.setOnClickListener(this);
        tv_tel.setOnClickListener(this);
        ll_wait_reply.setOnClickListener(this);
        btn_appeal.setOnClickListener(this);
        btn_refund.setOnClickListener(this);
        btn_change.setOnClickListener(this);
        btn_pay_now.setOnClickListener(this);
    }
    /*
    * 当前仅在乘客-长途中受用
    * */
    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()){
            case R.id.tv_wei://喂一下
                showToast("暂未开放");
                break;
            case R.id.tv_tel://电话
                if (!TextUtils.isEmpty(tv_phone.getText())){
                    CallPhone.callPhone(this,tv_phone.getText().toString().trim());
                }else {
                    showToast("电话为空");
                }
                break;
            case R.id.ll_wait_reply://异常订单中点击跳转处理结果页面
                Intent intent1 = new Intent(this, OrderExceptionResultActivity.class);
                intent1.putExtra("order",order);
                intent1.putExtra("identity",Constant.PASSENGER);
                startActivity(intent1);
                break;
            case R.id.btn_appeal://待服务；申诉
                if (go_type!=Constant.LONG_HURRY){
                    //showToast("跳转申诉页面");
                    jumpAppeal();
                }
                break;
            case R.id.btn_refund://待服务，退票
                if (go_type!=Constant.LONG_HURRY){
                    Intent intent = new Intent(this, PassengerTicketRefundActivity.class);
                    intent.putExtra("order",order);
                    intent.putExtra("go_type",go_type);
                    startActivity(intent);

                }
                break;
            case R.id.btn_change://待服务，改签
                if (go_type!=Constant.LONG_HURRY){
                    Intent intent = new Intent(this, ChangeTicketActivity.class);
                    intent.putExtra("order",order);
                    intent.putExtra("go_type",go_type);
                    startActivity(intent);
                }
                break;
            case R.id.button1://不一定时取消订单
                if (go_type!=Constant.LONG_HURRY){
                    //取消订单 待付款，待接单
                    if (order_type==Constant.WAIT_PAY||order_type==Constant.WAIT_TAKE){
                        if (order_type==Constant.WAIT_PAY){
                            //showToast("乘客—待付款—取消订单");
                            cancelOrder(order.getForm_way()+"",order_type+"",order.getOrder_id(),Constant.CANCEL_ORDER);
                        }else {
                            //showToast("乘客—长途—待接单—取消订单");
                            cancelOrder(order.getForm_way()+"",order_type+"",order.getOrder_id(),Constant.CANCEL_ORDER);
                        }
                        //申诉
                    }else if (order_type==Constant.IN_SURVICE||order_type==Constant.WAIT_FINISH||order_type==Constant.FINISHED){
                        if (order_type==Constant.IN_SURVICE){
                            //showToast("乘客—长途—服务中—申诉");
                            jumpAppeal();

                        }else if (order_type==Constant.WAIT_FINISH){
                            if (order.getIs_finished()==Constant.PASSENGER_FINISHED_HOST_NO){
                                //showToast("乘客—长途—等待对方完结—申诉");
                                jumpAppeal();
                            }else {
                                //showToast("乘客—长途—等待我完结—申诉");
                                jumpAppeal();
                            }

                        }else {
                            //showToast("乘客—长途—已完结—申诉");
                            jumpAppeal();

                        }
                        //取消申诉
                    }else if (order_type==Constant.EXCEPTION&&order.getIs_reply()==Constant.NO){
                        cancelAppealDialog();

                    }


                }

                break;
            case R.id.button2://不一定时立即购买
                if (go_type!=Constant.LONG_HURRY){
                    //立即支付
                    if (order_type==Constant.WAIT_PAY){
                        if (order.getForm_way()==Constant.RELEASE){
                            //showToast("乘客—长途—待付款—立即发布");
                            if (order.getIs_timeout()==Constant.NO){
                                jumpPay();
                            }else{
                                jumpRelease();
                            }


                        }else {
                            //showToast("乘客—长途—待付款—立即支付");
                            if (order.getIs_timeout()==Constant.NO){
                                Intent intent = new Intent(this, BookPayActivity.class);
                                intent.putExtra("orderCode",order.getOrder_id());
                                intent.putExtra("amount", order.getTotal_money()+"");
                                intent.putExtra("from", Constant.PASSENGER_ROB_PAY);
                                intent.putExtra("id",order.getService_id());
                                intent.putExtra("alipay",Common.PASSENGER_SEARCH_ALIPAY);
                                intent.putExtra("yivipay",Common.PASSENGER_SEARCH_RESTPAY);
                                startActivity(intent);
                            }

                        }

                        //我已上车
                    }else if (order_type==Constant.IN_SURVICE){
                        if (order.getIs_in_car()==Constant.YES){
                            JSONObject object = new JSONObject();
                            object.put("role",Constant.PASSENGER+"");
                            object.put("orderId",order.getOrder_id());
                            httpPost(Common.HOST+Common.ROUTE_FINISH,object,Constant.ROUTE_FINISHED);
                        }else {
                            JSONObject object = new JSONObject();
                            object.put("orderId",order.getOrder_id());
                            httpPost(Common.HOST+Common.ALREADY_IN_CAR,object,Constant.ALREADY_IN_CAR);
                        }

                        //行程完结
                    }else if (order_type==Constant.WAIT_FINISH){
                        if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                            //showToast("乘客—长途—等待我完结—行程完结");
                            JSONObject object = new JSONObject();
                            object.put("role",Constant.PASSENGER+"");
                            object.put("orderId",order.getOrder_id());
                            httpPost(Common.HOST+Common.ROUTE_FINISH,object,Constant.ROUTE_FINISHED);
                        }

                        //再次发布
                    }else if (order_type==Constant.FINISHED){
                        //showToast("乘客—长途—已完结—再次发布");
                        Intent intent = new Intent(this, ReleaseActivity.class);
                        intent.putExtra("identity",Constant.PASSENGER);
                        startActivity(intent);
                    }else if (order_type==Constant.WAIT_TAKE){
                        //退款，重新发布
                        Intent intent = new Intent(this, ReleaseActivity.class);
                        intent.putExtra("identity",Constant.PASSENGER);
                        startActivity(intent);
                    }
                }

                break;


        }
    }

    private void jumpRelease() {
        Intent intent = new Intent(this, ReleaseActivity.class);
        intent.putExtra("identity",Constant.PASSENGER);
        startActivity(intent);
    }

    /*
    * 跳转支付页面
    * */
    private void jumpPay() {
        Intent intent = new Intent(this, BookPayActivity.class);
        intent.putExtra("orderCode",order.getOrder_id());
        intent.putExtra("amount", order.getTotal_money()+"");
        intent.putExtra("from", Constant.PASSENGER_PUBLISH_PAY);
        intent.putExtra("id",order.getService_id());
        intent.putExtra("alipay", Common.PASSENGER_PUBLISH_ALIPAY);
        intent.putExtra("yivipay",Common.PASSENGER_PUBLISH_RESTPAY);
        startActivity(intent);
    }

    /*
    * 取消申诉
    * */
    private void cancelAppeal() {
        JSONObject object = new JSONObject();
        object.put("orderId",order.getOrder_id());
        httpPost(Common.HOST+Common.CANCEL_APPEAL,object,Constant.CANCEL_APPEAL);
    }
    /*
    * 跳转申诉页面
    * */
    private void jumpAppeal() {
        Intent intent = new Intent(this, FWHiteMeShopActivity.class);
        intent.putExtra("id",order.getOrder_id());//被举报人id
        intent.putExtra("from", Constant.PASSENGER_APPEAL);//标识
        startActivity(intent);
    }
    /*
    * 取消订单
    * */
    private void cancelOrder(String type, String serviceStatus, String orderId, String from) {
        JSONObject object = new JSONObject();
        object.put("type",type);
        object.put("serviceStatus",serviceStatus);
        object.put("orderId",orderId);
        httpPost(Common.HOST+Common.CANCEL_ORDER,object,from);
    }

    @Override
    public void onSuccess(String result, String fromWhere) {
        super.onSuccess(result, fromWhere);
        com.alibaba.fastjson.JSONObject obj = JSON.parseObject(result);
        JSONObject data = obj.getJSONObject("data");
        if (fromWhere.equals(Constant.CANCEL_ORDER)){
            showToast("取消订单成功");
            backResult(Constant.RESULT_CANCEL_ORDER);
        }else if (fromWhere.equals(Constant.ALREADY_IN_CAR)){
            showToast("我已上车");
            backResult(Constant.RELULT_IN_CAR);
        }else if (fromWhere.equals(Constant.ROUTE_FINISHED)){
            if (order_type==Constant.IN_SURVICE){
                showToast("服务中行程完结");
                backResult(Constant.RESULT_ROUTE_FINISH_IN_SERVICE);
            }else {
                showToast("待完结行程完结");
                backResult(Constant.RESULT_ROUTE_FINISH_WAIT_FINISH);
            }

        }else if (fromWhere.equals(Constant.CANCEL_APPEAL)){
            showToast("取消申诉");
            backResult(Constant.RESULT_CANCEL_APPEAL);
        }else if (fromWhere.equals(Constant.ORDER_DETAIL)){
            JSONObject orderDetail = data.getJSONObject("orderDetail");
            Order order = new Order();
            if (orderDetail.containsKey("vehicleAvatarList")){
                ArrayList<String> imgList = new ArrayList<>();
                JSONArray list = orderDetail.getJSONArray("vehicleAvatarList");
                for (int j = 0; j < list.size(); j++) {
                    String img = list.getString(j);
                    imgList.add(img);
                }
                order.setImgList(imgList);
            }else {
                order.setImgList(new ArrayList<String>());
            }

            tv_distance.setText(order.getDistance()+"公里");
            if (go_type!=Constant.LONG_HURRY&&order_type!=Constant.WAIT_TAKE&&order_type!=Constant.WAIT_PAY){
                if (order.getWho_created()==Constant.HOST){
                    text22.setText("我的留言：");
                    text11.setText("我的联系方式：");
                }else {
                    text22.setText("车主留言：");
                    text11.setText("车主联系方式：");
                }
            }
            switch (order_type){
                case Constant.WAIT_PAY:
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setSingle_money(orderDetail.getDouble("pinServiceAccount"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    //订单特有字段
                    order.setSeats(orderDetail.getIntValue("ownerHasSeats"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));

                    ////////////////////////////////////////
                    tv_distance.setText(order.getDistance()+"公里");
                    tv_seats.setText("座位需求"+order.getSeats()+"个");
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    ll_loss.setVisibility(View.GONE);
                    tv_phone.setText(order.getPhone());
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_order_type.setText("--待付款");
                    line1.setVisibility(View.GONE);
                    ll_pay_time.setVisibility(View.GONE);
                    ll_pay_type.setVisibility(View.GONE);
                    tv_loss.setVisibility(View.GONE);
                    if (TextUtils.isEmpty(order.getWords())){
                        tv_words.setText("暂无留言");
                    }else {
                        tv_words.setText(order.getWords());
                    }
                    tv_title.setText("订单详情");
                    text11.setText("车主联系方式：");
                    text22.setText("车主留言：");
                    Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                    if (TextUtils.isEmpty(order.getNickname())){
                        tv_nickname.setText("暂无昵称");

                    }else {
                        tv_nickname.setText(order.getNickname());

                    }
                    tv_recent_come.setText("[24h前来过]");// TODO: 2017/11/13 weiyixia
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    ArrayList<String> imgList = order.getImgList();
                    for (int i = 0; i <imgList.size() ; i++) {
                        x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList.get(i));
                    }
                    if (order.getIs_timeout()==Constant.YES){
                        tv_ticket_price.setText("已超时");
                    }else {
                        tv_ticket_price.setText("车票未购买成功，票价"+order.getSingle_money()+"元");
                        btn_pay_now.setText("购票");
                    }
                    break;
                case Constant.WAIT_SURVICE:
                    Log.e("WAIT_SURVICE","WAIT_SURVICE");
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setLeaveOffTime(orderDetail.getLong("leaveOffTime"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setLoss_money(orderDetail.getDouble("pinLoseAccount"));
                    order.setSingle_money(orderDetail.getDouble("pinServiceAccount"));

                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    order.setService_id(orderDetail.getString("serviceId"));

                    ///////////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    if (order.getWho_created()==Constant.HOST){

                        tv_seats.setText("座位需求"+order.getSeats()+"个");
                    }else {

                        tv_seats.setText("提供座位"+order.getSeats()+"个");

                    }
                    tv_order_type.setText("--待服务");
                    tv_tel.setVisibility(View.VISIBLE);
                    String str="<font color='#333333'>等待车主开始服务，感谢您的耐心等待</font>";
                    tv_ticket_price.setText(Html.fromHtml(str));
                    ll_bottom1.setVisibility(View.GONE);
                    ll_bottom2.setVisibility(View.VISIBLE);
                    ll_loss.setVisibility(View.VISIBLE);
                    tv_loss.setText("爽约金："+order.getLoss_money()+"元");
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    tv_phone.setText(order.getPhone());
                    tv_words.setText(order.getWords());

                    ArrayList<String> imgList4 = order.getImgList();

                    for (int i = 0; i < imgList4.size(); i++) {

                        x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList4.get(i));
                    }
                    Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                    tv_nickname.setText(order.getNickname());
                    tv_recent_come.setText("24h前来过");
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    if (order.getPay_type()==Constant.ALIPAY){
                        tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
                    }else if (order.getPay_type()==Constant.RESTPAY){
                        tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
                    }else {
                        tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
                    }
                    tv_pay_time.setText(order.getPay_time());
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }

                    break;
                case Constant.IN_SURVICE:
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));
                    order.setIs_in_car(orderDetail.getIntValue("isPasserOn"));

                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));
                    ////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_order_type.setText("--服务中");
                    if (order.getWho_created()==Constant.HOST){

                        tv_seats.setText("座位需求"+order.getSeats()+"个");
                    }else {

                        tv_seats.setText("提供座位"+order.getSeats()+"个");

                    }
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    tv_phone.setText(order.getPhone());
                    tv_words.setText(order.getWords());
                    tv_nickname.setText(order.getNickname());
                    tv_recent_come.setText("[24h前来过]");
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    tv_pay_time.setText(order.getPay_time());
                    if (order.getPay_type()==Constant.ALIPAY){
                        tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

                    }else if (order.getPay_type()==Constant.RESTPAY){
                        tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

                    }else {
                        tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

                    }
                    ArrayList<String> imgList1 = order.getImgList();
                    for (int i = 0; i < imgList1.size(); i++) {
                        x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList1.get(i));
                    }
                    Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                    ll_loss.setVisibility(View.GONE);
                    tv_tel.setVisibility(View.VISIBLE);
                    line2.setVisibility(View.GONE);
                    tv_ticket_price.setVisibility(View.GONE);
                    btn_cancel_order.setText("申诉");
                    if (order.getIs_in_car()==Constant.YES){
                        btn_pay_now.setText("行程完结");

                    }else {
                        btn_pay_now.setText("我已上车");

                    }
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    break;
                case Constant.WAIT_FINISH:
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    //1 完结 0 未完结
                    if (orderDetail.getIntValue("ownerEndStatus")==0&&orderDetail.getIntValue("passerEndStatus")==1){
                        order.setIs_finished(Constant.HOST_FINISHED_PASSENGER_NO);
                    }else if (orderDetail.getIntValue("ownerEndStatus")==1&&orderDetail.getIntValue("passerEndStatus")==0){
                        order.setIs_finished(Constant.PASSENGER_FINISHED_HOST_NO);
                    }else {
                        showToast("完结状态异常");
                    }

                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));
                    /////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    if (order.getWho_created()==Constant.HOST){

                        tv_seats.setText("座位需求"+order.getSeats()+"个");
                    }else {

                        tv_seats.setText("提供座位"+order.getSeats()+"个");

                    }
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    tv_phone.setText(order.getPhone());
                    tv_words.setText(order.getWords());
                    tv_nickname.setText(order.getNickname());
                    tv_recent_come.setText("[24h前来过]");
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    tv_pay_time.setText(order.getPay_time());
                    if (order.getPay_type()==Constant.ALIPAY){
                        tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

                    }else if (order.getPay_type()==Constant.RESTPAY){
                        tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

                    }else {
                        tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

                    }
                    ArrayList<String> imgList2 = order.getImgList();
                    Log.d("imageArray",imgList2.size()+"");
                    for (int i = 0; i < imgList2.size(); i++) {
                        Log.d("imageArray",imageArray[i]+"");
                        x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList2.get(i));
                    }
                    Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                    ll_loss.setVisibility(View.GONE);
                    tv_tel.setVisibility(View.VISIBLE);
                    line2.setVisibility(View.GONE);
                    tv_ticket_price.setVisibility(View.GONE);
                    btn_cancel_order.setText("申诉");
                    btn_pay_now.setText("行程完结");
                    if (order.getIs_finished()==Constant.PASSENGER_FINISHED_HOST_NO){
                        tv_order_type.setText("--等待对方完结");

                        btn_pay_now.setVisibility(View.GONE);
                    }else if (order.getIs_finished()==Constant.HOST_FINISHED_PASSENGER_NO){
                        tv_order_type.setText("--等待我完结");

                    }
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    break;
                case Constant.FINISHED:
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));

                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));
                    /////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_order_type.setText("--已完结");
                    if (order.getWho_created()==Constant.HOST){

                        tv_seats.setText("座位需求"+order.getSeats()+"个");
                    }else {

                        tv_seats.setText("提供座位"+order.getSeats()+"个");

                    }
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    tv_phone.setText(order.getPhone());
                    tv_words.setText(order.getWords());
                    tv_nickname.setText(order.getNickname());
                    tv_recent_come.setText("[24h前来过]");
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    tv_pay_time.setText(order.getPay_time());
                    if (order.getPay_type()==Constant.ALIPAY){
                        tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");

                    }else if (order.getPay_type()==Constant.RESTPAY){
                        tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");

                    }else {
                        tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");

                    }
                    ArrayList<String> imgList3 = order.getImgList();
                    for (int i = 0; i < imgList3.size(); i++) {
                        x.image().bind(imageArray[i],Common.IMAGE_HOST+imgList3.get(i));
                    }
                    Picasso.with(this).load(Common.IMAGE_HOST+order.getIcon()).error(R.mipmap.morentouxiang).transform(new CircleTransform()).into(iv_icon);
                    ll_loss.setVisibility(View.GONE);
                    tv_tel.setVisibility(View.VISIBLE);
                    line2.setVisibility(View.GONE);
                    tv_ticket_price.setVisibility(View.GONE);
                    btn_cancel_order.setText("申诉");
                    btn_pay_now.setText("再次发布");
                    btn_pay_now.setTextColor(getResources().getColor(R.color.hotcolor));
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    break;
                case Constant.LOSS:
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));
                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));

                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setLoss_money(orderDetail.getDouble("pinLoseAccount"));
                    order.setSingle_money(orderDetail.getDouble("pinServiceAccount"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));

                    ////////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_order_type.setText("--爽约单");
                    tv_style.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_order_type.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_distance.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_seats.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_seats.setText("爽约金 10元");
                    text55.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_total_price.setTextColor(getResources().getColor(R.color.textcolors));
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_car),null);

                    }
                    tv_title_info.setVisibility(View.VISIBLE);
                    iv_whoPay.setVisibility(View.VISIBLE);
                    ll_bottom1.setVisibility(View.GONE);
                    tv_loss.setText("需求5个座位");
                    line.setVisibility(View.GONE);
                    line2.setVisibility(View.GONE);
                    ll_id_info.setVisibility(View.GONE);
                    tv_ticket_price.setVisibility(View.GONE);
                    if (order.getWho_return()==Constant.ME){
                        SpannableString spannableString = new SpannableString("对方申诉我超时，我赔付，爽约金将赔付与对方，剩余金额450元将退还到您的账户，请查收");
                        spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#fc4c4c")), 26,30, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                        tv_title_info.setText(spannableString);

                        iv_whoPay.setImageResource(R.mipmap.wochaoshi);
                    }else {
                        SpannableString spannableString = new SpannableString("对方退票，对方赔付，爽约金50元稍后将到您的账户，请查收，感谢您的耐心等待");
                        spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#fc4c4c")), 13,16, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                        tv_title_info.setText(spannableString);

                        iv_whoPay.setImageResource(R.mipmap.duifangtuipiao);
                    }
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    break;
                case Constant.EXCEPTION:
                    order.setIs_reply(orderDetail.getIntValue("complaintHandleStatus"));
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setPay_time(DateUtil.times(orderDetail.getLong("orderPayTime")));
                    order.setPay_type(orderDetail.getIntValue("orderPayType"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setIcon(orderDetail.getString("ownerAvatar"));
                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setOwnerId(orderDetail.getString("ownerId"));
                    order.setNickname(orderDetail.getString("ownerNickName"));

                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    order.setLoss_money(orderDetail.getDouble("pinLoseAccount"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setVehicle_type(orderDetail.getIntValue("vehicleType"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setWho_created(orderDetail.getIntValue("orderCreateBy"));

                    //////////////////////////////////////
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_title.setText("订单异常订单详情");
                    tv_order_type.setText("--订单异常");
                    tv_distance.setText(order.getDistance()+"公里");
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    tv_loss.setText("需求"+order.getSeats()+"个座位");
                    tv_seats.setText("爽约金 "+order.getLoss_money()+"元");

                    tv_phone.setText(order.getPhone());
                    tv_words.setText(order.getWords());
                    tv_order_id.setText(order.getOrder_code());
                    tv_pay_time.setText(order.getPay_time());
                    if (order.getPay_type()==Constant.ALIPAY){
                        if (order.getWho_created()==Constant.PASSENGER){
                            tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
                        }else {
                            tv_pay_type.setText("支付宝支付"+order.getLoss_money()+"元");

                        }
                    }else if (order.getPay_type()==Constant.RESTPAY){
                        if (order.getWho_created()==Constant.PASSENGER){
                            tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
                        }else {
                            tv_pay_type.setText("余额支付"+order.getLoss_money()+"元");

                        }
                    }else {
                        if (order.getWho_created()==Constant.PASSENGER){
                            tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
                        }else {
                            tv_pay_type.setText("微信支付"+order.getLoss_money()+"元");

                        }
                    }
                    tv_start_time.setText(order.getStart_time());
                    tv_style.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_order_type.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_distance.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_seats.setTextColor(getResources().getColor(R.color.textcolors));
                    text55.setTextColor(getResources().getColor(R.color.textcolors));
                    tv_total_price.setTextColor(getResources().getColor(R.color.textcolors));
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.grey_car),null);

                    }
                    if (order.getIs_reply()==Constant.YES){
                        ll_bottom1.setVisibility(View.GONE);
                    }else {
                        ll_wait_reply.setVisibility(View.VISIBLE);
                        btn_pay_now.setVisibility(View.GONE);
                        btn_cancel_order.setText("取消申诉");
                    }

                    line.setVisibility(View.GONE);
                    line2.setVisibility(View.GONE);
                    ll_id_info.setVisibility(View.GONE);
                    tv_ticket_price.setVisibility(View.GONE);
                    if (order.getVehicle_type()==Constant.BUS){
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.bus),null);
                    }else {
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,getResources().getDrawable(R.mipmap.car1),null);
                    }
                    break;
            }

        }else if (fromWhere.equals(Constant.SERVICE_DETAIL)){
            JSONObject orderDetail = data.getJSONObject("orderDetail");
            Order order = new Order();
            if (orderDetail.containsKey("vehicleAvatarList")){
                ArrayList<String> imgList = new ArrayList<>();
                JSONArray list = orderDetail.getJSONArray("vehicleAvatarList");
                for (int j = 0; j < list.size(); j++) {
                    String img = list.getString(j);
                    imgList.add(img);
                }
                order.setImgList(imgList);
            }else {
                order.setImgList(new ArrayList<String>());
            }

            tv_distance.setText(order.getDistance()+"公里");
            if (go_type!=Constant.LONG_HURRY&&order_type!=Constant.WAIT_TAKE&&order_type!=Constant.WAIT_PAY){
                if (order.getWho_created()==Constant.HOST){
                    text22.setText("我的留言：");
                    text11.setText("我的联系方式：");
                }else {
                    text22.setText("车主留言：");
                    text11.setText("车主联系方式：");
                }
            }
            if (order_type==Constant.WAIT_PAY){
                if (!serviceId.equals("")){//服务详情
                    order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                    order.setPhone(orderDetail.getString("mobile"));
                    order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                    order.setEnd_place(orderDetail.getString("pinEndPoint"));
                    order.setSingle_money(orderDetail.getDouble("pinServiceAccount"));
                    order.setService_code(orderDetail.getString("pinServiceCode"));
                    order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                    order.setStart_place(orderDetail.getString("pinStartPoint"));
                    order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                    order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                    order.setService_id(orderDetail.getString("serviceId"));
                    order.setOrder_id(orderDetail.getString("orderId"));
                    order.setOrder_code(orderDetail.getString("orderCode"));
                    order.setIs_timeout(orderDetail.getIntValue("orderTimeOut"));
                    order.setWords(orderDetail.getString("pinLeaveWords"));
                    //服务特有字段
                    order.setSeats(orderDetail.getIntValue("passerRequireSeats"));

                    ////////////////////////////////////////
                    tv_distance.setText(order.getDistance()+"公里");
                    tv_seats.setText("座位需求"+order.getSeats()+"个");
                    tv_total_price.setText(order.getTotal_money()+"元");
                    tv_depart_time.setText(order.getDepart_time());
                    tv_start_pos.setText(order.getStart_place());
                    tv_end_pos.setText(order.getEnd_place());
                    ll_loss.setVisibility(View.GONE);
                    tv_phone.setText(order.getPhone());
                    tv_order_id.setText(order.getOrder_code());
                    tv_start_time.setText(order.getStart_time());
                    if (go_type==Constant.LONG){
                        tv_style.setText("长途");
                    }else if (go_type==Constant.CITY){
                        tv_style.setText("同城");
                    }else if (go_type==Constant.TRAVEL){
                        tv_style.setText("旅游");
                    }
                    tv_order_type.setText("--待付款");
                    line1.setVisibility(View.GONE);
                    ll_pay_time.setVisibility(View.GONE);
                    ll_pay_type.setVisibility(View.GONE);
                    tv_loss.setVisibility(View.GONE);
                    if (TextUtils.isEmpty(order.getWords())){
                        tv_words.setText("暂无留言");
                    }else {
                        tv_words.setText(order.getWords());
                    }
                    //服务详情
                        tv_title.setText("发布详情");
                        ll_images.setVisibility(View.GONE);
                        line.setVisibility(View.GONE);
                        ll_id_info.setVisibility(View.GONE);
                        text11.setText("我的联系方式：");
                        text22.setText("我的留言：");
                        tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
                        if (order.getIs_timeout()==Constant.YES){
                            tv_ticket_price.setText("已超时");
                            btn_pay_now.setText("重新发布");

                        }else {
                    /*SpannableString spannableString = new SpannableString("信息未发布,票价100元");
                    spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#fc4c4c")), 6,spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);*/
                            tv_ticket_price.setText("信息未发布,票价"+order.getSingle_money()+"元");
                            btn_pay_now.setText("立即发布");

                        }


                }
            }else if (order_type==Constant.WAIT_TAKE){
                order.setStart_time(DateUtil.times(orderDetail.getLong("pinCreateTime")));
                order.setDepart_time(DateUtil.times(orderDetail.getLong("leaveOffTime")));
                order.setPay_type(orderDetail.getIntValue("orderPayType"));
                order.setSeats(orderDetail.getIntValue("passerRequireSeats"));

                order.setEnd_place(orderDetail.getString("pinEndPoint"));
                order.setWords(orderDetail.getString("pinLeaveWords"));

                order.setService_code(orderDetail.getString("pinServiceCode"));
                order.setStyle(orderDetail.getIntValue("pinServiceKinds"));
                order.setStart_place(orderDetail.getString("pinStartPoint"));
                order.setTotal_money(orderDetail.getDouble("pinTotalAccount"));
                order.setDistance(orderDetail.getDouble("pinTotalDistance"));
                order.setService_id(orderDetail.getString("serviceId"));
                order.setPay_time(DateUtil.times(orderDetail.getLong("servicePayTime")));
                order.setPhone(orderDetail.getString("mobile"));
                order.setOrder_code(orderDetail.getString("orderCode"));

                tv_distance.setText(order.getDistance()+"公里");
                tv_seats.setText("需求座位"+order.getSeats()+"个");
                tv_total_price.setText(order.getTotal_money()+"元");
                tv_depart_time.setText(order.getDepart_time());
                tv_start_pos.setText(order.getStart_place());
                tv_end_pos.setText(order.getEnd_place());
                //tv_loss.setText("爽约金："+order.getLoss_money()+"元");
                tv_phone.setText(order.getPhone());
                if (TextUtils.isEmpty(order.getWords())){
                    tv_words.setText("乘客很懒，没有留言");
                }else {
                    tv_words.setText(order.getWords());
                }
                tv_order_id.setText(order.getOrder_code());
                tv_pay_time.setText(order.getPay_time());
                if (order.getPay_type()==Constant.ALIPAY){
                    tv_pay_type.setText("支付宝支付"+order.getTotal_money()+"元");
                }else if (order.getPay_type()==Constant.RESTPAY){
                    tv_pay_type.setText("余额支付"+order.getTotal_money()+"元");
                }else {
                    tv_pay_type.setText("微信支付"+order.getTotal_money()+"元");
                }
                tv_start_time.setText(order.getStart_time());
                if (go_type==Constant.LONG){
                    tv_style.setText("长途");
                }else if (go_type==Constant.CITY){
                    tv_style.setText("同城");
                }else if (go_type==Constant.TRAVEL){
                    tv_style.setText("旅游");
                }
                tv_order_type.setText("--待接单");
                ll_images.setVisibility(View.GONE);
                line.setVisibility(View.GONE);
                ll_id_info.setVisibility(View.GONE);
                text11.setText("我的电话：");
                text22.setText("我的留言：");
                if (order.getIs_timeout()==Constant.YES){
                    tv_ticket_price.setText("已超时");
                    btn_pay_now.setVisibility(View.VISIBLE);
                    btn_pay_now.setText("重新发布");

                }else {
                    String str="<font color='#333333'>待车主接单，感谢您的耐心等待</font>";
                    tv_ticket_price.setText(Html.fromHtml(str));
                    btn_pay_now.setVisibility(View.GONE);

                }
                ll_loss.setVisibility(View.GONE);
                tv_style.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
            }
        }
    }
    /*
    *返回上一级result
    * */
    private void backResult(int result_code) {
        Intent intent = new Intent();
        intent.putExtra("position",position);
        setResult(result_code,intent);
        finish();
    }
    /*
    *取消申诉弹窗
    * */
    private  void cancelAppealDialog(){
        AlertDialog.Builder builder = null;
        builder = new AlertDialog.Builder(AppManager.getAppManager().currentActivity());
        View view = LayoutInflater.from(AppManager.getAppManager().currentActivity()).inflate(R.layout.dialog_layout, null);
        builder.setView(view);
        TextView cancel = (TextView) view.findViewById(R.id.dialog_cancel);
        TextView sure = (TextView) view.findViewById(R.id.dialog_sure);
        TextView message = (TextView) view.findViewById(R.id.dialog_text);
        sure.setText("确定");
        cancel.setText("取消");
        message.setText("您确定要取消申诉么？");
        final AlertDialog dialog = builder.create();
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cancelAppeal();
                dialog.dismiss();
            }
        });
        dialog.show();
    }

}
